#define LED_5 D6
#define LED_4 D5
#define LED_3 D4
#define LED_2 D3
#define LED_1 D2
#define BUTTON D0

int button_state = 0; 
int previous_state = 1;
int a = 0;

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin USER_LED_R as an output.
  Serial.begin(9600);
  pinMode(LED_1, OUTPUT);
  pinMode(LED_2, OUTPUT);
  pinMode(LED_3, OUTPUT);
  pinMode(LED_4, OUTPUT);
  pinMode(LED_5, OUTPUT);
  pinMode(BUTTON, INPUT);

  digitalWrite(LED_5, LOW);  
  digitalWrite(LED_4, LOW);  
  digitalWrite(LED_3, LOW);  
  digitalWrite(LED_2, LOW);  
  digitalWrite(LED_1, LOW); 
}

// the loop function runs over and over again forever
void loop() {
  button_state = digitalRead(BUTTON);
  if(button_state == LOW && previous_state == HIGH){
    if(a == 0) {
      digitalWrite(LED_1, HIGH);
      Serial.println("BLUE LED ON");
    }

    else if(a == 1) {
      digitalWrite(LED_2, HIGH);
      Serial.println("RED LED ON");
    }

    else if(a == 2) {
      digitalWrite(LED_3, HIGH);
      Serial.println("WHITE LED ON");
    }

    else if(a == 3) {
      digitalWrite(LED_4, HIGH);
      Serial.println("YELLOW LED ON");
    }

    else if(a == 4) {
      digitalWrite(LED_5, HIGH);
      Serial.println("GREEN ON");
    }

    else if(a >= 5){
      delay(200);
      digitalWrite(LED_1, LOW);
      digitalWrite(LED_2, LOW);
      digitalWrite(LED_3, LOW);
      digitalWrite(LED_4, LOW);
      digitalWrite(LED_5, LOW);
      Serial.println("ALL LED OFF");
      a = -1;
    }
    a++;
    delay(200); 
  }
  previous_state = button_state;
}
